import pytest
from helium import *
from config.config import URL
from library.logger import log


@pytest.fixture
def login():
    try:
        start_chrome(URL)
        log.info(f'打开Chrome浏览器访问url：{URL}')
        driver = get_driver()
        driver.maximize_window()
        log.info('浏览器窗口最大化')
        Config.implicit_wait_secs = 30
        log.info('设置隐性等待时间为30s')
    except Exception as e:
        log.error(e)
    else:
        yield driver
        log.info('关闭浏览器')
        kill_browser()
